<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>生源地人数统计报表</title>

    <!--表格-->
    <style>
        .el-table .warning-row {
            background: oldlace;
        }

        .el-table .success-row {
            background: #f0f9eb;
        }

        .el-header{
            background-color: #B3C0D1;
            color: #333;
            text-align: center;
            line-height: 60px;
            font-size: 30px;
        }

        .el-main {
            background-color: #E9EEF3;
            color: #333;
            text-align: left;
            line-height: 50px;
        }

        .el-footer{
            background-color: #B3C0D1;
            color: #333;
            text-align: center;
            line-height: 60px;

        }

    </style>
</head>
<body>
<div id="app">
    <el-container>
        <el-header><div>生源地人数统计报表</div></el-header>
        <el-main>

            <!--按钮-->
            <el-row>
                <el-button type="success" icon="el-icon-folder-opened" @click="PrintPage">打印</el-button>
            </el-row><br>

            <!--表格-->
            <template>
                <el-table
                        :data="tableData"
                        style="width: 100%"
                        :row-class-name="tableRowClassName"
                        @selection-change="handleSelectionChange">
                    <el-table-column
                            type="index">
                    </el-table-column>
                    <el-table-column
                            prop="originPlace"
                            label="生源地"
                            align="center">
                    </el-table-column>
                    <el-table-column
                            prop="sum"
                            label="人数"
                            align="center">
                    </el-table-column>
                </el-table>
            </template>


        </el-main>
    </el-container>


</div>

<script src="js/vue.js"></script>
<script src="element-ui/lib/index.js"></script>
<link rel="stylesheet" href="element-ui/lib/theme-chalk/index.css">
<script src="js/axios-0.18.0.js"></script>

<script>
    new Vue({
        el: "#app",

        mounted() {
            this.selectAll();

        },

        methods: {

            //----------------分页查询数据---------------
            selectAll() {

                var _this = this;

                axios({
                    method: "post",
                    url: "http://localhost:8080/teaching/depart/selectCountPlace?currentPage=" + _this.currentPage + "&pageSize=" + _this.pageSize,
                    data: _this.count
                }).then(function (resp) {
                    _this.tableData = resp.data.rows;
                    _this.totalCount = resp.data.totalCount;
                })
            },


            tableRowClassName({row, rowIndex}) {
                if (rowIndex%4 === 1) {
                    return 'warning-row';
                } else if (rowIndex%4 === 3) {
                    return 'success-row';
                }
                return '';
            },

            //----------------每页的条目数发送变化----------------
            handleSizeChange(val) {
                //console.log(`每页 ${val} 条`);
                //重新设置每页显示条数
                this.pageSize = val;
                this.selectAll();
            },

            //---------------页码发送变化查询的条数--------------
            handleCurrentChange(val) {
                //console.log(`当前页: ${val}`);
                //重新设置当前页码
                this.currentPage = val;
                this.selectAll();
            },


            //退出系统
            exit(){
                window.open('http://localhost:8080/bookstore/login.jsp','_blank')
            },

            PrintPage(){
                window.print();
            },

            //刷新
            openFullScreen() {
                const loading = this.$loading({
                    lock: true,
                    text: 'Loading',
                    spinner: 'el-icon-loading',
                    background: 'rgba(0, 0, 0, 0.7)'
                });
                setTimeout(() => {
                    loading.close();
                    location.reload();
                }, 1000);
            }
        },

        data() {
            return {
                //每页显示的条数
                pageSize: 20,

                //总记录数
                totalCount: 100,

                //分页工具条的当前页码
                currentPage: 1,


                //书籍的数据
                count: {
                    originPlace: '',
                    sum:'',
                },

                //表格数据
                tableData: [{
                    originPlace: '广东',
                    sum:'1',
                }, {
                    originPlace: '广东',
                    sum:'1',
                }, {
                    originPlace: '广东',
                    sum:'1',
                }, {
                    originPlace: '广东',
                    sum:'1',
                }]
            }
        }
    })


</script>

</body>
</html>